<?php

namespace App\Http\Controllers;

use App\Exceptions\BusinessException;
use App\Services\ActivityService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ActivityController extends Controller
{
    /**
     * 活动列表
     * @param Request $request
     * @return JsonResponse
     */
    public function list(Request $request)
    {
        $page = $request->input('page', 1);
        $pageSize = $request->input('psize', 10);
        $keyword = $request->input('keyword');
        $state = $request->input('state');
        $data = ActivityService::getInstance()->list($page, $pageSize, $keyword, $state);
        return $this->success($data);
    }

    /**
     * 活动详情
     * @param Request $request
     * @return JsonResponse
     * @throws BusinessException
     */
    public function detail(Request $request)
    {
        $activityId = $request->input('activity_id', 0);
        $data = ActivityService::getInstance()->detail($activityId);
        return $this->success($data);
    }
}
